package com.oauth.dao.imp;

import com.oauth.dao.interf.IUserService;
import com.oauth.dao.repository.UserRepository;
import com.oauth.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class UserService implements IUserService , UserDetailsService {
    @Autowired
    private UserRepository userRepository;
    @Override
    public UserModel findByPhone(String phone){
        return userRepository.findByPhone(phone);
    }
    @Override
    public UserModel findByUsername(String username){
        return userRepository.findByUsername(username);
    }
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException{
        return userRepository.findByUsername(username);
    }

}
